package com.ff.device.config;

import com.ff.device.quatz.DeviceStatusJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuartzConfig {
	
	@Bean
    public JobDetail deviceQuartzDetail(){
        return JobBuilder.newJob(DeviceStatusJob.class).withIdentity("updateDeviceStatus").storeDurably().build();
    }

    @Bean
    public Trigger deviceQuartzTrigger(){
        SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule()
                .withIntervalInSeconds(60*5)  //设置时间周期单位秒
                .repeatForever();
        return TriggerBuilder.newTrigger().forJob(deviceQuartzDetail())
                .withIdentity("updateDeviceStatus")
                .withSchedule(scheduleBuilder)
                .build();
    }

}
